var aPic=getByClass("pic");
var aTrash=getByClass("trash");
for(var i=0;i<aPic.length;i++) {
    aPic[i].index = i;
    aPic[i].onmouseover = function () {
        var aPicdiv = getByClass("pic-div");
        aPicdiv[this.index].style.display = "block";
        for (var j = 0; j < aTrash.length; j++) {
            aTrash[j].index2 = j;
            aTrash[j].onclick = function () {
                var aGoods = getByClass("goods");
                aGoods[this.index2].style.display = "none";
                aGoods[this.index2 + 1].className = aGoods[this.index2].className;
            }
        }
    }
        aPic[i].onmouseout = function () {
            var aPicdiv = getByClass("pic-div");
            aPicdiv[this.index].style.display = "none";
        }
    }


function getByClass(sClassName) {
    var aEls = document.getElementsByTagName("*"); //选择确定父元素内所有元素
    var arr = [];
    for (var i = 0; i < aEls.length; i++) {
        var aClassName = aEls[i].className.split(' '); //将所选元素的classname拆分为数组
        for (var j = 0; j < aClassName.length; j++) {//遍历这个数组进行判断
            if (aClassName[j] == sClassName) {
                arr.push(aEls[i]); //将含有要找的className的元素存在数组中
            }
        }
    }
    return arr; //得到在确定父元素下具有某个className的所有元素，然后就可以方便的调用了
}
